<?php

function bbcode($texto) {
	  $tags = array(
			  //Básicos
			  '/(?<!\\\\)\[code(?::\w+)?\](.*?)\[\/code(?::\w+)?\]/si' => "<pre class=\"prettyprint linenums\">\\1</pre>",
			  '/(?<!\\\\)\[b(?::\w+)?\](.*?)\[\/b(?::\w+)?\]/si'                 => "<span class=\"negrito\">\\1</span>",
			  '/(?<!\\\\)\[img(?::\w+)?\](.*?)\[\/img(?::\w+)?\]/si'             => "<a href=\"\\1\" title=\"Ampliar\" class=\"highslide\" onclick=\"return hs.expand (this)\"><img class=\"imagembb\" src=\"\\1\" alt=\"Imagem\" /></a>",

	  );
	  $texto = preg_replace(array_keys($tags), array_values($tags), $texto);
	  return $texto;
	}

?>